/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PMO_Dialog.java
 *
 * Created on Mar 23, 2012, 1:23:26 PM
 */
package Com.Interface;

import Com.Controller.MainController;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;
import javax.swing.*;

/**
 *
 * @author Tea-Nose
 */
public class PMO_Dialog extends javax.swing.JDialog {

    /** Creates new form PMO_Dialog */
    private JLabel nilaiNama_Label;
    private JLabel nilaiAlamat_Label;
    private JLabel nilaiJenisKelamin_Label;
    private JTextField nilaiID_Label;
    private JLabel nilaiSaran_Label;
    private String tahapPengobatan;
    private String noRegLab;

    public PMO_Dialog(java.awt.Frame parent, boolean modal, JLabel nilaiNama_Label, JLabel nilaiAlamat_Label, JLabel nilaiJenisKelamin_Label,
            JTextField nilaiID_Label, JLabel nilaiSaran_Label, String tahapPengobatan, String noRegLab) {
        super(parent, modal);
        this.nilaiNama_Label = nilaiNama_Label;
        this.nilaiAlamat_Label = nilaiAlamat_Label;
        this.nilaiJenisKelamin_Label = nilaiJenisKelamin_Label;
        this.nilaiID_Label = nilaiID_Label;
        this.nilaiSaran_Label = nilaiSaran_Label;
        this.tahapPengobatan = tahapPengobatan;
        this.noRegLab = noRegLab;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dataPmoPanel = new javax.swing.JPanel();
        namaLabel = new javax.swing.JLabel();
        alamatLabel = new javax.swing.JLabel();
        namaTextField = new javax.swing.JTextField();
        alamatScrollPane = new javax.swing.JScrollPane();
        alamatTextArea = new javax.swing.JTextArea();
        lanjutButton = new javax.swing.JButton();
        kembaliButton = new javax.swing.JButton();
        peringatanabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        dataPmoPanel.setBackground(new java.awt.Color(255, 255, 255));
        dataPmoPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATA PMO", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Arial", 1, 14), new java.awt.Color(0, 153, 51))); // NOI18N
        dataPmoPanel.setLayout(null);

        namaLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        namaLabel.setText("Nama");
        dataPmoPanel.add(namaLabel);
        namaLabel.setBounds(30, 40, 60, 14);

        alamatLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        alamatLabel.setText("Alamat");
        dataPmoPanel.add(alamatLabel);
        alamatLabel.setBounds(30, 90, 60, 14);

        namaTextField.setText("Nama_PMO");
        namaTextField.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                namaTextFieldMouseClicked(evt);
            }
        });
        dataPmoPanel.add(namaTextField);
        namaTextField.setBounds(90, 40, 270, 20);

        alamatTextArea.setColumns(20);
        alamatTextArea.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N
        alamatTextArea.setRows(5);
        alamatTextArea.setText("Alamat_PMO");
        alamatTextArea.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                alamatTextAreaMouseClicked(evt);
            }
        });
        alamatScrollPane.setViewportView(alamatTextArea);

        dataPmoPanel.add(alamatScrollPane);
        alamatScrollPane.setBounds(90, 90, 270, 100);

        lanjutButton.setText("Lanjut");
        lanjutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lanjutButtonActionPerformed(evt);
            }
        });
        dataPmoPanel.add(lanjutButton);
        lanjutButton.setBounds(90, 240, 80, 23);

        kembaliButton.setText("Kembali");
        kembaliButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kembaliButtonActionPerformed(evt);
            }
        });
        dataPmoPanel.add(kembaliButton);
        kembaliButton.setBounds(230, 240, 80, 23);

        peringatanabel.setFont(new java.awt.Font("Arial", 1, 12));
        peringatanabel.setForeground(new java.awt.Color(255, 0, 0));
        peringatanabel.setText("*PMO harus dapat dipercaya untuk membantu konsumsi obat pasien");
        dataPmoPanel.add(peringatanabel);
        peringatanabel.setBounds(14, 194, 390, 40);

        getContentPane().add(dataPmoPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 410, 300));

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void lanjutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lanjutButtonActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        try {
            MainController.insertRekamMedis(namaTextField.getText(), alamatTextArea.getText(), noRegLab);
            MainController.cetakPrintOut(nilaiNama_Label, nilaiAlamat_Label, nilaiJenisKelamin_Label, nilaiID_Label, namaTextField.getText(), alamatTextArea.getText(), nilaiSaran_Label);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(PMO_Dialog.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(PMO_Dialog.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(PMO_Dialog.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_lanjutButtonActionPerformed

    private void kembaliButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kembaliButtonActionPerformed
        // TODO add your handling code here:
        countAlamat = 0;
        countNama = 0;
        this.setVisible(false);
    }//GEN-LAST:event_kembaliButtonActionPerformed

    private void alamatTextAreaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_alamatTextAreaMouseClicked
        // TODO add your handling code here:
        if (countAlamat == 0) {
            alamatTextArea.setText("");
            countAlamat++;
        }
    }//GEN-LAST:event_alamatTextAreaMouseClicked

    private void namaTextFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_namaTextFieldMouseClicked
        // TODO add your handling code here:
        if (countNama == 0) {
            namaTextField.setText("");
            countNama++;
        }
    }//GEN-LAST:event_namaTextFieldMouseClicked
    /**
     * @param args the command line arguments
     */
    /* public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {

    public void run() {
    PMO_Dialog dialog = new PMO_Dialog(new javax.swing.JFrame(), true);
    dialog.addWindowListener(new java.awt.event.WindowAdapter() {

    @Override
    public void windowClosing(java.awt.event.WindowEvent e) {
    System.exit(0);
    }
    });
    dialog.setVisible(true);
    }
    });
    }*/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel alamatLabel;
    private javax.swing.JScrollPane alamatScrollPane;
    private javax.swing.JTextArea alamatTextArea;
    private javax.swing.JPanel dataPmoPanel;
    private javax.swing.JButton kembaliButton;
    private javax.swing.JButton lanjutButton;
    private javax.swing.JLabel namaLabel;
    private javax.swing.JTextField namaTextField;
    private javax.swing.JLabel peringatanabel;
    // End of variables declaration//GEN-END:variables
    private int countNama = 0;
    private int countAlamat = 0;
}
